﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Linq.Expressions;
using System.Linq.Dynamic;
using NewsInfo;
public partial class ocx_land_search_table : System.Web.UI.UserControl
{
    Expression<Func<NewsInfo.NewsInfo, bool>> searchPredicate;
    protected void Page_Load(object sender, EventArgs e)
    {
        NameValueCollection nvcParam = new NameValueCollection(Request.QueryString);
        searchPredicate = PredicateExtensions.True<NewsInfo.NewsInfo>();
        foreach (string key in nvcParam)
        {
            string condition = string.Empty;
            switch (key)
            {
                case "NewsID":
                    condition = nvcParam[key];
                    searchPredicate = searchPredicate.And(u => u.NewsID.ToString().Contains(condition));
                    break;
                case "NewsTitle":
                    condition = nvcParam[key];
                    searchPredicate = searchPredicate.And(u => u.NewsTitle.Contains(condition));
                    break;
                case "NewsCategory":
                    condition = nvcParam[key];
                    searchPredicate = searchPredicate.And(u => u.NewsCategory.ToString().Contains(condition));
                    break;
                default:
                    break;
            }
        }
        AspNetPager1.RecordCount = NewsInfoControl.GetCount(searchPredicate);
    }
    void bindData()
    {

        List<NewsInfo.NewsInfo> hhh = NewsInfoControl.GetList(AspNetPager1.StartRecordIndex, AspNetPager1.PageSize, searchPredicate);
        Repeater1.DataSource = hhh;
        Repeater1.DataBind();
    }
    protected void AspNetPager1_PageChanged(object src, EventArgs e)
    {
        bindData();
    }
    protected string GetStatus(string statusNumber)
    {
        switch (statusNumber)
        {
            case "Newsletter":
                return "时事新闻";
                break;
            case "Financial":
                return "财经新闻";
                break;
            case "Fun":
                return "娱乐新闻";
                break;
            case "Sports":
                return "体育新闻";
                break;
            default:
                return "";
                break;
        }
    }

}
